<template>
	<view >
		 <button type="primary" @click="cs">调节屏幕亮度</button>
		 <button @click="start">开始监听陀螺仪变化</button>
		 <button @click="stop">停止监听陀螺仪变化</button>
		 {{msg_s}}-----{{msg_r}}
	</view>
</template>

<script>
	export default {
		data() {
			return {
				href: 'https://uniapp.dcloud.io/component/README?id=uniui',
				msg_s:'',
				msg_r:'',
			}
		},
		methods: {
			start() {
			            uni.onGyroscopeChange((res) => {
			                console.log('gyroData.rotationRate.x = ' + res.x)
			                console.log('gyroData.rotationRate.y = ' + res.y)
			                console.log('gyroData.rotationRate.z = ' + res.z)
			            });
			            uni.startGyroscope({
			                interval: "normal",
			                success() {
			                    console.log('success')
			                },
			                fail() {
			                    console.log('fail')
			                }
			            })
			        },
			        stop(){
			            uni.stopGyroscope({
			                success() {
			                    console.log('stop success!')
			                },
			                fail() {
			                    console.log('stop fail!')
			                }
			            })
			        },
					
			cs(){
				// uni.getNetworkType({
				//     success: function (res) {
				//         console.log(res.networkType);
				//     }
				// });
				// uni.setScreenBrightness({
				//     value: 0.5,
				//     success: function () {
				//         console.log('success');
				//     }
				// });
				// uni.getScreenBrightness({
				//     success: function (res) {
				//         console.log('屏幕亮度值：' + res.value);
				//     }
				// });
				// uni.makePhoneCall({
				//     phoneNumber: '114' //仅为示例
				// });
				// let that = this
				// uni.scanCode({
				//     success: function (res) {
				//         console.log('条码类型：' + res.scanType);
				// 		that.msg_s = res.scanType
				//         console.log('条码内容：' + res.result);
				// 		that.msg_r = res.result
				//     }
				// });
				uni.scanCode({
				    scanType: ['barCode'],
				    success: function (res) {
				        console.log('条码类型：' + res.scanType);
						that.msg_s = res.scanType
				        console.log('条码内容：' + res.result);
						that.msg_r = res.result
				    }
				});
			}
		}
	}
</script>

<style>

</style>
